import "./index.scss";
import { useNavigate, useLocation } from "react-router-dom";

const CourseDetail3 = () => {
  //时间转换
  const toDub = (n: any) => (n < 10 ? "0" + n : "" + n);
  //年月日时分秒
  const toTime = (date: any) => {
    const oTime = new Date(date);
    return (
      oTime.getFullYear() +
      "-" +
      toDub(oTime.getMonth() + 1) +
      "-" +
      toDub(oTime.getDate()) +
      " " +
      toDub(oTime.getHours()) +
      ":" +
      toDub(oTime.getMinutes()) +
      ":" +
      toDub(oTime.getSeconds())
    );
  };

  //取数据
  const state = useLocation();
  console.log("state", state.state);

  //返回上一个页面
  const navigate = useNavigate();
  const back = () => {
    navigate("/home/NewCourse");
  };

  return (
    <div className="teacherDetail">
      <div className="top">
        <div className="top-l">
          <div className="title" onClick={back}>
            新课程审批
          </div>
          <div>&gt;</div>
          <div className="detail">详情</div>
        </div>
      </div>

      <div className="hr"></div>

      <div className="con1">
        <div className="name">{state.state.ocourse}</div>
        <div className="state">{state.state.ocstate}</div>
      </div>

      <div className="context-box">
        <div className="con2">
          <div className="detail">
            <div className="allTitle">
              <div className="title">所属机构</div>
              <div className="title">培养目标</div>
              <div className="title">招生人数</div>
              <div className="title">招生范围</div>
              <div className="title">学费标准</div>
              <div className="title">培训时间</div>
              <div className="title">通过时间</div>
            </div>
            <div>
              <div className="text">{state.state.oname}</div>
              <div className="text">{state.state.ogoal}</div>
              <div className="text">每个班不超过30</div>
              <div className="text">{state.state.orange}</div>
              <div className="text">{state.state.ostand}</div>
              <div className="text">{state.state.oform}</div>
              <div className="text">{toTime(state.state.ocpasstime)}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
};

export default CourseDetail3;
